#!/bin/bash
current = shell("networksetup -getairportnetwork {}|awk -v FS=': ' '{{print $2}}'".format(device))
print("Now Wi-Fi: {}".format(current))
return current

def mac_switch_wifi(name):
if name and platform.system() == 'Darwin':
    device = shell("networksetup -listallhardwareports|grep 'Hardware Port: Wi-Fi' -A1|grep 'Device:'|awk -v FS=': ' '{print $2}'")
    print("Wi-Fi Device: {}".format(device))
    current = mac_now_wifi(device)
    if current != name:
        shell("networksetup -setairportnetwork {} {}".format(device, name))
        print("Switched To: {}".format(name))
        mac_now_wifi(device)
    return current